<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="google" value="notranslate">
  <title>BlocklyPi</title>
  <link rel="stylesheet" href="style.css"> 
  <script src="../../blockly_compressed.js"></script>
  <script src="../../blocks_compressed.js"></script>
  <script src="../../python_compressed.js"></script>
  
  <script src="../../pi/define_pins.js"></script>
  
  <!--Pi blocks Lib-->
  <script src="../../pi/blocks/inout.js"></script>
  <script src="../../pi/blocks/pwm.js"></script>
  <script src="../../pi/blocks/time.js"></script>
  <script src="../../pi/blocks/console.js"></script>
  <script src="../../pi/blocks/thread.js"></script>
  <script src="../../pi/blocks/file.js"></script>
  <script src="../../pi/blocks/network.js"></script>
  <script src="../../pi/blocks/serial.js"></script>
  <script src="../../pi/blocks/display.js"></script>
  <script src="../../pi/blocks/device.js"></script>
  <script src="../../pi/blocks/utils.js"></script>
  <script src="../../pi/blocks/factory.js"></script>
  <!--Pi generators Lib-->
  <script src="../../pi/generators/inout.js"></script>
  <script src="../../pi/generators/pwm.js"></script>
  <script src="../../pi/generators/time.js"></script>
  <script src="../../pi/generators/console.js"></script>
  <script src="../../pi/generators/thread.js"></script>
  <script src="../../pi/generators/file.js"></script>
  <script src="../../pi/generators/network.js"></script>
  <script src="../../pi/generators/serial.js"></script>
  <script src="../../pi/generators/display.js"></script>
  <script src="../../pi/generators/device.js"></script>
  <script src="../../pi/generators/utils.js"></script>
  <script src="../../pi/generators/factory.js"></script>

  <script src="code.js"></script>
  
  <script type="text/javascript" src="Blob.js"></script>
  <script type="text/javascript" src="spin.js"></script>
  <script type="text/javascript" src="FileSaver.min.js"></script>
  <script type="text/javascript" src="blockly_helper.js"></script>
</head>
<body>
  <table width="100%" height="100%">
    <tr>
      <td>
        <h1><a>BlocklyPi</a>web-based visual programming editor for RaspBerryPi<small>By HGC&amp;Beta版本</small>
          <span id="title">...</span>
        </h1>
      </td>
      <td class="farSide">
        <select id="languageMenu"></select>
      </td>
    </tr>
    <tr>
      <td colspan=2>
        <table width="100%">
          <tr id="tabRow" height="1em">
            <td id="tab_blocks" class="tabon">...</td>
            <td class="tabmin">&nbsp;</td>
            <td id="tab_python" class="taboff">Python</td>
            <td class="tabmin">&nbsp;</td>
            <td id="tab_xml" class="taboff">XML</td>
            <td class="tabmax">
            <button onclick="saveCode()">保存为Python代码</button>
            <button onclick="save()">保存为XML文件</button>
            <button id="fakeload">从XML文件读取</button>
            <input type="file" id="load" style="display: none;"/>
            <button id="trashButton" class="notext" title="..."><img src='../../media/1x1.gif' class="trash icon21"></button>


            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td height="99%" colspan=2 id="content_area">
      </td>
    </tr>
  </table>
  <div id="content_blocks" class="content"></div>
  <pre id="content_python" class="content"></pre>
  <textarea id="content_xml" class="content" wrap="off"></textarea>

  <xml id="toolbox" style="display: none">
    <category name="%{BKY_CATLOGIC}" colour="%{BKY_LOGIC_HUE}">
      <block type="controls_if"></block>
      <block type="logic_compare"></block>
      <block type="logic_operation"></block>
      <block type="logic_negate"></block>
      <block type="logic_boolean"></block>
      <block type="logic_null"></block>
      <block type="logic_ternary"></block>
    </category>
    <category name="%{BKY_CATLOOPS}" colour="%{BKY_LOOPS_HUE}">
      <block type="controls_repeat_ext">
        <value name="TIMES">
          <shadow type="math_number">
            <field name="NUM">10</field>
          </shadow>
        </value>
      </block>
      <block type="controls_whileUntil"></block>
      <block type="controls_for">
        <value name="FROM">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
        <value name="TO">
          <shadow type="math_number">
            <field name="NUM">10</field>
          </shadow>
        </value>
        <value name="BY">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
      </block>
      <block type="controls_forEach"></block>
      <block type="controls_flow_statements"></block>
    </category>
    <category name="%{BKY_CATMATH}" colour="%{BKY_MATH_HUE}">
      <block type="math_number">
        <field name="NUM">123</field>
      </block>
      <block type="math_arithmetic">
        <value name="A">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
        <value name="B">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
      </block>
      <block type="math_single">
        <value name="NUM">
          <shadow type="math_number">
            <field name="NUM">9</field>
          </shadow>
        </value>
      </block>
      <block type="math_trig">
        <value name="NUM">
          <shadow type="math_number">
            <field name="NUM">45</field>
          </shadow>
        </value>
      </block>
      <block type="math_constant"></block>
      <block type="math_number_property">
        <value name="NUMBER_TO_CHECK">
          <shadow type="math_number">
            <field name="NUM">0</field>
          </shadow>
        </value>
      </block>
      <block type="math_round">
        <value name="NUM">
          <shadow type="math_number">
            <field name="NUM">3.1</field>
          </shadow>
        </value>
      </block>
      <block type="math_on_list"></block>
      <block type="math_modulo">
        <value name="DIVIDEND">
          <shadow type="math_number">
            <field name="NUM">64</field>
          </shadow>
        </value>
        <value name="DIVISOR">
          <shadow type="math_number">
            <field name="NUM">10</field>
          </shadow>
        </value>
      </block>
      <block type="math_constrain">
        <value name="VALUE">
          <shadow type="math_number">
            <field name="NUM">50</field>
          </shadow>
        </value>
        <value name="LOW">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
        <value name="HIGH">
          <shadow type="math_number">
            <field name="NUM">100</field>
          </shadow>
        </value>
      </block>
      <block type="math_random_int">
        <value name="FROM">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
        <value name="TO">
          <shadow type="math_number">
            <field name="NUM">100</field>
          </shadow>
        </value>
      </block>
      <block type="math_random_float"></block>
    </category>
    <category name="%{BKY_CATTEXT}" colour="%{BKY_TEXTS_HUE}">
      <block type="text"></block>
      <block type="text_join"></block>
      <block type="text_append">
        <value name="TEXT">
          <shadow type="text"></shadow>
        </value>
      </block>
      <block type="text_length">
        <value name="VALUE">
          <shadow type="text">
            <field name="TEXT">abc</field>
          </shadow>
        </value>
      </block>
      <block type="text_isEmpty">
        <value name="VALUE">
          <shadow type="text">
            <field name="TEXT"></field>
          </shadow>
        </value>
      </block>
      <block type="text_indexOf">
        <value name="VALUE">
          <block type="variables_get">
            <field name="VAR">{textVariable}</field>
          </block>
        </value>
        <value name="FIND">
          <shadow type="text">
            <field name="TEXT">abc</field>
          </shadow>
        </value>
      </block>
      <block type="text_charAt">
        <value name="VALUE">
          <block type="variables_get">
            <field name="VAR">{textVariable}</field>
          </block>
        </value>
      </block>
      <block type="text_getSubstring">
        <value name="STRING">
          <block type="variables_get">
            <field name="VAR">{textVariable}</field>
          </block>
        </value>
      </block>
      <block type="text_changeCase">
        <value name="TEXT">
          <shadow type="text">
            <field name="TEXT">abc</field>
          </shadow>
        </value>
      </block>
      <block type="text_trim">
        <value name="TEXT">
          <shadow type="text">
            <field name="TEXT">abc</field>
          </shadow>
        </value>
      </block>
      <block type="text_print">
        <value name="TEXT">
          <shadow type="text">
            <field name="TEXT">abc</field>
          </shadow>
        </value>
      </block>
      <block type="text_prompt_ext">
        <value name="TEXT">
          <shadow type="text">
            <field name="TEXT">abc</field>
          </shadow>
        </value>
      </block>
    </category>
    <category name="%{BKY_CATLISTS}" colour="%{BKY_LISTS_HUE}">
      <block type="lists_create_with">
        <mutation items="0"></mutation>
      </block>
      <block type="lists_create_with"></block>
      <block type="lists_repeat">
        <value name="NUM">
          <shadow type="math_number">
            <field name="NUM">5</field>
          </shadow>
        </value>
      </block>
      <block type="lists_length"></block>
      <block type="lists_isEmpty"></block>
      <block type="lists_indexOf">
        <value name="VALUE">
          <block type="variables_get">
            <field name="VAR">{listVariable}</field>
          </block>
        </value>
      </block>
      <block type="lists_getIndex">
        <value name="VALUE">
          <block type="variables_get">
            <field name="VAR">{listVariable}</field>
          </block>
        </value>
      </block>
      <block type="lists_setIndex">
        <value name="LIST">
          <block type="variables_get">
            <field name="VAR">{listVariable}</field>
          </block>
        </value>
      </block>
      <block type="lists_getSublist">
        <value name="LIST">
          <block type="variables_get">
            <field name="VAR">{listVariable}</field>
          </block>
        </value>
      </block>
      <block type="lists_split">
        <value name="DELIM">
          <shadow type="text">
            <field name="TEXT">,</field>
          </shadow>
        </value>
      </block>
      <block type="lists_sort"></block>
    </category>
    <category name="%{BKY_CATCOLOUR}" colour="%{BKY_COLOUR_HUE}">
      <block type="colour_picker"></block>
      <block type="colour_random"></block>
      <block type="colour_rgb">
        <value name="RED">
          <shadow type="math_number">
            <field name="NUM">100</field>
          </shadow>
        </value>
        <value name="GREEN">
          <shadow type="math_number">
            <field name="NUM">50</field>
          </shadow>
        </value>
        <value name="BLUE">
          <shadow type="math_number">
            <field name="NUM">0</field>
          </shadow>
        </value>
      </block>
      <block type="colour_blend">
        <value name="COLOUR1">
          <shadow type="colour_picker">
            <field name="COLOUR">#ff0000</field>
          </shadow>
        </value>
        <value name="COLOUR2">
          <shadow type="colour_picker">
            <field name="COLOUR">#3333ff</field>
          </shadow>
        </value>
        <value name="RATIO">
          <shadow type="math_number">
            <field name="NUM">0.5</field>
          </shadow>
        </value>
      </block>
    </category>
    <sep></sep>
    <category name="%{BKY_CATVARIABLES}" colour="%{BKY_VARIABLES_HUE}" custom="VARIABLE"></category>
    <category name="%{BKY_CATFUNCTIONS}" colour="%{BKY_PROCEDURES_HUE}" custom="PROCEDURE"></category>
    <sep></sep>
    
    <category name="输入/输出" colour="20">
      <block type="inout_pins"></block>
      <block type="inout_mode">
        <value name="PIN">
          <shadow type="inout_pins"></shadow>
        </value>
      </block>
      <block type="inout_highlow"></block>
      <block type="inout_output">
        <value name="PIN">
          <shadow type="inout_pins"></shadow>
        </value>
        <value name="STAT">
          <shadow type="inout_highlow"></shadow>
        </value>
      </block>
      <block type="inout_input">
        <value name="PIN">
          <shadow type="inout_pins"></shadow>
        </value>
      </block>
    </category>
    <category name="PWM" colour="45">
      <block type="pwm_init">
        <value name="PIN">
          <shadow type="inout_pins"></shadow>
        </value>
        <value name="FREQ">
          <shadow type="math_number">
            <field name="NUM">50</field>
          </shadow>
        </value>
      </block>
      <block type="pwm_start">
        <value name="DUTY">
          <shadow type="math_number">
            <field name="NUM">50</field>
          </shadow>
        </value>
      </block>
      <block type="pwm_freq">
        <value name="FREQ">
          <shadow type="math_number">
            <field name="NUM">50</field>
          </shadow>
        </value>
      </block>
      <block type="pwm_duty">
        <value name="DUTY">
          <shadow type="math_number">
            <field name="NUM">50</field>
          </shadow>
        </value>
      </block>
      <block type="pwm_stop"></block>
    </category>
    <category name="延时" colour="120">
      <block type="time_delay">
          <value name="DELAY_TIME">
            <shadow type="math_number">
               <field name="NUM">1</field>
            </shadow>
         </value>
      </block>
      <block type="time_delay_ms">
          <value name="DELAY_TIME">
            <shadow type="math_number">
               <field name="NUM">10</field>
            </shadow>
         </value>
      </block>
      <block type="time_delay_us">
          <value name="DELAY_TIME">
            <shadow type="math_number">
               <field name="NUM">10</field>
            </shadow>
         </value>
      </block>
    </category>
    <category name="控制台" colour="230">
      <block type="console_print">
        <value name="MESSAGE">
          <shadow type="text">
            <field name="TEXT">Hello world</field>
          </shadow>
        </value>
      </block>
      <block type="console_input">
        <value name="MESSAGE">
          <shadow type="text">
            <field name="TEXT">Please enter the text:</field>
          </shadow>
        </value>
      </block>
      <block type="console_shell">
        <value name="SHELL">
          <shadow type="text">
            <field name="TEXT">ls</field>
          </shadow>
        </value>
      </block>
      <block type="console_shellout">
        <value name="SHELL">
          <shadow type="text">
            <field name="TEXT">ls</field>
          </shadow>
        </value>
      </block>
    </category>
    <category name="多线程" colour="230">
      <block type="thread_thread_init"></block>
      <block type="thread_thread_initblock"></block>
      <block type="thread_thread_start"></block>
      <block type="thread_lock_init"></block>
      <block type="thread_lock_acquire"></block>
      <block type="thread_lock_release"></block>
      <block type="thread_semaphore_init">
        <value name="VALUE">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
      </block>
      <block type="thread_semaphore_acquire"></block>
      <block type="thread_semaphore_release"></block>
      <block type="thread_event_init"></block>
      <block type="thread_event_set"></block>
      <block type="thread_event_wait"></block>
    </category>
    <category name="文件系统" colour="0">
      <block type="file_read">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./file.txt</field>
          </shadow>
        </value>
      </block>
      <block type="file_write">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./file.txt</field>
          </shadow>
        </value>
        <value name="CONTENT">
          <shadow type="text">
            <field name="TEXT">Hello world</field>
          </shadow>
        </value>
      </block>
      <block type="file_isfile">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./file.txt</field>
          </shadow>
        </value>
      </block>
      <block type="file_remove">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./file.txt</field>
          </shadow>
        </value>
      </block>
      <block type="file_listdir">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./folder</field>
          </shadow>
        </value>
      </block>
      <block type="file_mkdir">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./folder</field>
          </shadow>
        </value>
      </block>
      <block type="file_isdir">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./folder</field>
          </shadow>
        </value>
      </block>
      <block type="file_rmdir">
        <value name="PATH">
          <shadow type="text">
            <field name="TEXT">./folder</field>
          </shadow>
        </value>
      </block>
    </category>
    <category name="网络" colour="0">
      <block type="network_get">
        <value name="URL">
          <shadow type="text">
            <field name="TEXT">http://192.168.0.100</field>
          </shadow>
        </value>
      </block>
      <block type="network_getout">
        <value name="URL">
          <shadow type="text">
            <field name="TEXT">http://192.168.0.100</field>
          </shadow>
        </value>
      </block>
      <block type="network_tcp_init">
        <value name="HOST">
          <block type="text">
            <field name="TEXT">192.168.0.100</field>
          </block>
        </value>
        <value name="PORT">
          <block type="math_number">
            <field name="NUM">8888</field>
          </block>
        </value>
      </block>
      <block type="network_tcp_close"></block>
      <block type="network_tcp_recv">
        <value name="SIZE">
          <shadow type="math_number">
            <field name="NUM">10</field>
          </shadow>
        </value>
      </block>
      <block type="network_tcp_send">
        <value name="DATA">
          <shadow type="text">
            <field name="TEXT">hello</field>
          </shadow>
        </value>
      </block>
    </category>
    <category name="串口" colour="65">
      <block type="serial_init">
        <value name="DEV_FILE">
          <block type="text">
            <field name="TEXT">/dev/tty0</field>
          </block>
        </value>
        <value name="BAUD">
          <block type="math_number">
            <field name="NUM">9600</field>
          </block>
        </value>
        <value name="TIMEOUT">
          <block type="math_number">
            <field name="NUM">0.5</field>
          </block>
        </value>
      </block>
      <block type="serial_open"></block>
      <block type="serial_isopen"></block>
      <block type="serial_close"></block>
      <block type="serial_inwaiting"></block>
      <block type="serial_flushinput"></block>
      <block type="serial_read">
        <value name="SIZE">
          <shadow type="math_number">
            <field name="NUM">10</field>
          </shadow>
        </value>
      </block>
      <block type="serial_readline"></block>
      <block type="serial_write">
        <value name="DATA">
          <shadow type="text">
            <field name="TEXT">hello</field>
          </shadow>
        </value>
      </block>
    </category>
    <category name="显示器" colour="180">
      <block type="display_lcd1602_init">
        <value name="BUS">
          <shadow type="factory_var">
            <field name="VALUE">1</field>
          </shadow>
        </value>
        <value name="LCD_ADDR">
          <shadow type="factory_var">
            <field name="VALUE">0x27</field>
          </shadow>
        </value>
      </block>
      <block type="display_lcd1602_print">
        <value name="x">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
        <value name="y">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
        <value name="STR">
          <shadow type="text">
            <field name="TEXT">hello</field>
          </shadow>
        </value>
      </block>
      <block type="display_lcd1602_printline">
        <value name="STR1">
          <block type="text">
            <field name="TEXT"></field>
          </block>
        </value>
        <value name="STR2">
          <block type="text">
            <field name="TEXT"></field>
          </block>
        </value>
      </block>
      <block type="display_lcd1602_clear"></block>
      <block type="display_oled_init">
        <value name="BUS">
          <shadow type="factory_var">
            <field name="VALUE">1</field>
          </shadow>
        </value>
        <value name="OLED_ADDR">
          <shadow type="factory_var">
            <field name="VALUE">0x3C</field>
          </shadow>
        </value>
      </block>
      <block type="display_oled_print">
        <value name="x">
          <shadow type="math_number">
            <field name="NUM">0</field>
          </shadow>
        </value>
        <value name="y">
          <shadow type="math_number">
            <field name="NUM">0</field>
          </shadow>
        </value>
        <value name="STR">
          <shadow type="text">
            <field name="TEXT">Hello world!</field>
          </shadow>
        </value>
      </block>
      <block type="display_oled_printline">
        <value name="STR1">
          <block type="text">
            <field name="TEXT"></field>
          </block>
        </value>
        <value name="STR2">
          <block type="text">
            <field name="TEXT"></field>
          </block>
        </value>
        <value name="STR3">
          <block type="text">
            <field name="TEXT"></field>
          </block>
        </value>
        <value name="STR4">
          <block type="text">
            <field name="TEXT"></field>
          </block>
        </value>
      </block>
      <block type="display_oled_clear"></block>
      <block type="display_tm1637_init">
        <value name="CLK">
          <shadow type="inout_pins">
            <field name="PIN">7</field>
          </shadow>
        </value>
        <value name="DIO">
          <shadow type="inout_pins">
            <field name="PIN">11</field>
          </shadow>
        </value>
      </block>
      <block type="display_tm1637_number">
        <value name="NUM">
          <shadow type="math_number">
            <field name="NUM">1234</field>
          </shadow>
        </value>
      </block>
      <block type="display_tm1637_print">
        <value name="STR">
          <block type="text">
            <field name="TEXT">Help</field>
          </block>
        </value>
      </block>
      <block type="display_tm1637_ratio">
        <value name="NUM1">
          <shadow type="math_number">
            <field name="NUM">12</field>
          </shadow>
        </value>
        <value name="NUM2">
          <shadow type="math_number">
            <field name="NUM">34</field>
          </shadow>
        </value>
      </block>
      <block type="display_tm1637_temperature">
        <value name="TEMP">
          <shadow type="math_number">
            <field name="NUM">-5</field>
          </shadow>
        </value>
      </block>
      <block type="display_tm1637_clear"></block>
    </category>
    <category name="外部设备" colour="100">
      <block type="device_dht11">
        <value name="PIN">
          <shadow type="inout_pins">
            <field name="PIN">7</field>
          </shadow>
        </value>
      </block>
      <block type="device_bmp180">
        <value name="BUS">
          <shadow type="factory_var">
            <field name="VALUE">1</field>
          </shadow>
        </value>
        <value name="BMP180_ADDR">
          <shadow type="factory_var">
            <field name="VALUE">0x77</field>
          </shadow>
        </value>
      </block>
      <block type="device_hcsr04_distance">
        <value name="TRIG">
          <shadow type="inout_pins">
            <field name="PIN">7</field>
          </shadow>
        </value>
        <value name="ECHO">
          <shadow type="inout_pins">
            <field name="PIN">11</field>
          </shadow>
        </value>
      </block>
      <block type="device_ads1115">
        <value name="BUS">
          <shadow type="factory_var">
            <field name="VALUE">1</field>
          </shadow>
        </value>
        <value name="ADS1115_ADDR">
          <shadow type="factory_var">
            <field name="VALUE">0x48</field>
          </shadow>
        </value>
      </block>
      <block type="device_stepper_init">
        <value name="PIN1">
          <block type="inout_pins">
            <field name="PIN">31</field>
          </block>
        </value>
        <value name="PIN2">
          <block type="inout_pins">
            <field name="PIN">33</field>
          </block>
        </value>
        <value name="PIN3">
          <block type="inout_pins">
            <field name="PIN">35</field>
          </block>
        </value>
        <value name="PIN4">
          <block type="inout_pins">
            <field name="PIN">37</field>
          </block>
        </value>
        <value name="STEPS">
          <block type="math_number">
            <field name="NUM">100</field>
          </block>
        </value>
        <value name="SPEED">
          <block type="math_number">
            <field name="NUM">50</field>
          </block>
        </value>
      </block>
      <block type="device_stepper_step">
        <value name="STEPS">
          <shadow type="math_number">
            <field name="NUM">500</field>
          </shadow>
        </value>
      </block>
      <block type="device_beep">
        <value name="PIN">
          <shadow type="inout_pins">
            <field name="PIN">7</field>
          </shadow>
        </value>
        <value name="FREQ">
          <shadow type="math_number">
            <field name="NUM">220</field>
          </shadow>
        </value>
        <value name="TIME">
          <shadow type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
      </block>
    </category>
    
    <sep></sep>
    <category name="Utils" colour="75">
      <block type="utils_now"></block>
      <block type="utils_time"></block>
      <block type="utils_break"></block>
      <block type="utils_int"></block>
      <block type="utils_long"></block>
      <block type="utils_float"></block>
      <block type="utils_str"></block>
    </category>
    <category name="Factory" colour="75">
      <block type="factory_import"></block>
      <block type="factory_do"></block>
      <block type="factory_block"></block>
      <block type="factory_var"></block>
    </category>
  </xml>

</body>
</html>